package generation.aggregation;
import org.jfugue.Pattern;
import org.jfugue.PatternListener;
import org.jfugue.Player;
import org.jfugue.StreamingPlayer;


public class PatternListenerImpl implements PatternListener {

	StreamingPlayer streamingPlayer;
	Player player;
	
	public PatternListenerImpl(StreamingPlayer player) {
		this.player = null;
		this.streamingPlayer = player;
	}

	public PatternListenerImpl(Player player) {
		this.player = player;
		this.streamingPlayer = null;
	}

	public void fragmentAdded(Pattern arg0) {
		if (this.player != null){
			//System.out.println("Player");
			player.play(arg0);
		} else {
			streamingPlayer.close();
			streamingPlayer = new StreamingPlayer(false);
			streamingPlayer.stream(arg0);
		}
	}
}
